import React from 'react';

import DatasourceTable from '../../../components/DatasourceTabel'
import usePublic from '../public';

export default function Vector() {
  const {pagination,onSearch,sortChange,tableData,pageChange} = usePublic('0101')

  const connectRender = (_,row) => {
    if (['shapeFolder', 'fgdb', 'mdb'].indexOf(row.type) > -1) {
      if (row.fileSource === 'SMBstore') {
        return JSON.parse(row.config).path;
      } else {
        return row.config;
      }
    } else {
      try {
        const config = JSON.parse(row.config);
        return `${config.ip}:${config.port}/${config.database}`;
      } catch (error) {
        console.log(error);
      }
    }
  }
  return (
    <DatasourceTable
      pagination={pagination}
      onSearch={onSearch}
      sortChange={sortChange}
      tableData={tableData}
      pageChange={pageChange}
      connectRender={connectRender}
    ></DatasourceTable>
  );
}

